Skip to content

Fix/version stamping#82

Open
Davanum Srinivas (dims) wants to merge 1 commit into
agent-substrate:mainfrom
dims:fix/version-stamping
Open

Fix/version stamping#82
Davanum Srinivas (dims) wants to merge 1 commit into
agent-substrate:mainfrom
dims:fix/version-stamping

Conversation

@dims
Copy link
Copy Markdown
Collaborator

Adds a pkg/version package and wires -ldflags -X through the Makefile + hack/install-ate.sh. All six binaries (kubectl-ate, atenet, ateapi, atelet, ateom-gvisor, podcertcontroller) now respond to --version and print something!

Please share what you think ... exactly we should print :)

Fixes #<issue_number_goes_here>

It's a good idea to open an issue first for discussion.

  • Tests pass
  • Appropriate changes to documentation are included in the PR

Comment thread internal/version/version.go
Davanum Srinivas (dims) added a commit to dims/substrate that referenced this pull request May 26, 2026
Per review feedback on PR agent-substrate#82: the version package is consumed only
by substrate's own binaries, so it belongs under internal/ where the
Go toolchain enforces that nothing outside the module can import it.

Pure rename + import-path update; no behavioural change. Verified
kubectl-ate --version still prints the expected line and linux
servers still build with -ldflags.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Davanum Srinivas (dims) added a commit to dims/substrate that referenced this pull request May 26, 2026
Per review feedback on PR agent-substrate#82: the version package is consumed only
by substrate's own binaries, so it belongs under internal/ where the
Go toolchain enforces that nothing outside the module can import it.

Pure rename + import-path update; no behavioural change. Verified
kubectl-ate --version still prints the expected line and linux
servers still build with -ldflags.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Davanum Srinivas (dims) added a commit to dims/substrate that referenced this pull request May 26, 2026
Two CI failures on PR agent-substrate#82:

1. run-tests: gofmt reordered the internal/version import in
   cmd/ateapi/main.go (alphabetical within the substrate import
   group).

2. e2e-test: hack/install-ate.sh's run_ko wrapper passed --ldflags
   unconditionally, but the pinned ko version rejects that flag on
   ko apply. Guard the injection with a case statement so --ldflags
   only goes on build / publish / resolve.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Adds internal/version with three vars (Version, Commit, BuildDate) set
via -ldflags -X at build time. When unset (e.g. plain `go build`
without LDFLAGS), runtime/debug.ReadBuildInfo() populates them from the
embedded vcs info so `go install`, `go run`, and ko-built images
(buildvcs is on by default) still produce something meaningful.

Wired through:
  - Makefile: VERSION / COMMIT / BUILD_DATE resolved from `git describe`
    / `git rev-parse` / `date`. LDFLAGS plumbed into every go-build and
    ko-build target (build-images, build-atectl, build-atenet,
    build-demos).
  - hack/install-ate.sh: untouched here — ko apply / resolve don't
    accept --ldflags, and ko's buildvcs embedding gives Commit +
    BuildDate automatically through runtime/debug.ReadBuildInfo() in
    the version package's init() fallback.

All six binaries respond to `--version`:
  - kubectl-ate and atenet (cobra): rootCmd.Version = version.String()
  - ateapi, atelet, ateom-gvisor, podcertcontroller (flag): explicit
    `-version` bool that prints and exits.

Sample output:
  kubectl-ate version 3b0a0d5 commit=3b0a0d5c2... \
      built=2026-05-26T14:16:53Z darwin/arm64

Closes the "kubectl-ate --version has nothing to print" gap; gives ops
a way to tell at a glance which commit a deployed substrate component
came from.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@BenTheElder
Copy link
Copy Markdown
Collaborator

Adds a pkg/version package and wires -ldflags -X through the Makefile + hack/install-ate.sh. All six binaries (kubectl-ate, atenet, ateapi, atelet, ateom-gvisor, podcertcontroller) now respond to --version and print something!

For a greenfield effort, did we consider https://pkg.go.dev/runtime/debug#BuildInfo instead of depending on ldflags?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants